<template>
  <div class="wallet">
    <van-nav-bar>
      <div slot="title" class="title">{{title}}</div>
      <van-icon size="22" name="/img/48.png" slot="left" @click="goBack" />
      <div slot="right" class="right" @click="goTransactionRecord">{{right}}</div>
    </van-nav-bar>
    <div class="my_balance_box">
      <div class="my_balance">
        <div class="my_balance_header">
          <div class="my_balance_text">我的金额</div>
          <div class="price">
            ¥
            <span class="price_num">{{userInfo.user_money}}</span>
          </div>
        </div>
        <div class="my_balance_bottom">
          <div class="this_month_cost">
            <p>上月支出（元）</p>
            <div class="month_cost">{{userInfo.last_month || 0}}</div>
          </div>
          <div class="upper_month_cost">
            <p>本月支出（元）</p>
            <div class="month_cost">{{userInfo.this_month||0}}</div>
          </div>
        </div>
      </div>
    </div>
    <router-link class="now_recharge" to="rechangeDivision">立即充值</router-link>
  </div>
</template>

<script>
import { NavBar, Icon } from "vant";
import {getUserInfo} from '@/utils/libs'
Vue.use(NavBar).use(Icon);
export default {
  name: "wallet",
  data() {
    return {
      userInfo: getUserInfo(),
      title: "我的钱包",
      right: "交易记录",
      myBalance: 3.27,
      thisMonthCost: 24.4,
      upperMonthCost: 199.2
    };
  },
  mounted(){
    this.getData()
  },
  components: {},
  methods: {
    getData(){
      this.$store.dispatch('wallet', {}).then(res => {
        console.log('wallert', res.data)
        this.userInfo = res.data.result
      }).catch(err => {

      })
    },
    goBack() {
      window.history.length > 1 ? this.$router.go(-1) : this.$router.push("/");
    },
    goTransactionRecord() {
      this.$router.push("/myTransactionRecord");
    }
  }
};
</script>
<style lang="less" rel="stylesheet/less" scoped>
.wallet {
  height: 100vh;
  background: rgba(247, 247, 247, 1);
  .title {
    font-size: 16px;
    font-family: PingFangSC-Medium;
    font-weight: 550;
    color: rgba(48, 48, 48, 1);
  }
  .right {
    font-size: 13px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(22, 89, 139, 1);
  }
  .my_balance_box {
    padding: 19px 10px 0 8px;
    .my_balance {
      padding: 13px 15px 0 15px;
      height: 180px;
      background-color: #fff;
      box-sizing: border-box;
      .my_balance_header {
        font-size: 13px;
        font-family: PingFangSC-Medium;
        font-weight: 700;
        color: rgba(48, 48, 48, 1);
        height: 87px;
        border-bottom: 1px solid #d8d8d8;
        .price {
          font-size: 18px;
          font-family: PingFangSC-Medium;
          font-weight: 700;
          color: rgba(225, 52, 52, 1);
          height: 59px;
          margin-top: 10px;
          .price_num {
            font-size: 42px;
          }
        }
      }
      .my_balance_bottom {
        p {
          margin: 0;
          padding: 0;
          font-size: 13px;
          font-family: PingFangSC-Regular;
          font-weight: 400;
          color: rgba(102, 102, 102, 1);
        }
        .month_cost {
          line-height: 27px;
          font-size: 20px;
          font-family: PingFangSC-Regular;
          font-weight: 400;
          color: rgba(48, 48, 48, 1);
        }
        margin-top: 15px;
        overflow: hidden;
        .this_month_cost,
        .upper_month_cost {
          float: left;
          width: 50%;
          box-sizing: border-box;
        }
        .this_month_cost {
          border-right: 1px dashed rgba(223, 223, 223, 1);
        }
        .upper_month_cost {
          padding-left: 27px;
        }
      }
    }
  }
  .now_recharge {
    margin: 0 auto;
    margin-top: 172px;
    width: 333px;
    height: 41px;
    line-height: 41px;
    text-align: center;
    display: block;
    background: linear-gradient(
      90deg,
      rgba(1, 47, 64, 1) 0%,
      rgba(1, 47, 64, 1) 100%
    );
    font-size: 15px;
    font-family: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(255, 255, 255, 1);
  }
}
</style>
